<?php

require "web.config.php";
 

 class mainController
 {

   
  
     //--------------------------------用户管理
     static $tb='user';
   public function user($param){  
   	global $m; 	    
    $output = show(self::$tb,-1);    
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
    
        function useredit($param){    
  	global $m; 	
   $output = show(self::$tb,$param);
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');
     }
     
     
       function userview($param){    
  	global $m; 	
   $output = show(self::$tb,$param);
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');
     }
    
    function userupdate(){
    	 	global $m; 	
$dt = $_POST['data'];
$id = $_POST['id'];
$myValue = update(self::$tb,$dt,$id,("user/main/user"));
}
    
   
     
     
       function userdel($param){
       	 global $m; 
   $myValue = del(self::$tb,$param,"?{$_SERVER["QUERY_STRING"]}&a=user");   
     }
     
     
      public   function userjson($param){             
    
   $myValue = tableToJson(self::$tb);
   echo $myValue;
    }
    
    
       //上传组件
         function userUp($name){         	
global $m;
$myValue =upload_file($name,"100*100");  
   }
     
     
        //--------------------------------用户充值记录
     static $pl='paylog';
   public function paylog($param){  
   	global $m; 	 
   	
   	if($param!=0)
   	{
   		$w=sprintf("where u.openid='%s'",$param);
   	}	   
    $output = show(sprintf('select * from %s p left join user u on p.userId=u.Id %s  order by time desc',self::$pl,$w),'sql');
    
//  var_dump($output);
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }
    
    
         function paylogdel($param){
       	 global $m; 
   $myValue = del(self::$pl,$param,"?{$_SERVER["QUERY_STRING"]}&a=".self::$pl);   
     }     
     
     
     
      //--------------------------------用户购买记录
     static $ps='pay_state';
   public function buylog($param){  
   	global $m; 
   	if($param!=0)
   	{
   		$w=sprintf("where u.openid='%s'",$param);
   	}	
   	 $output = show(sprintf('select * from %s p left join sale_code s on p.productId=s.Id left join user u on u.Id=p.userId %s order by p.time desc',self::$ps,$w),'sql');
    
//var_dump($output);
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }
    
    
    
         function buylogdel($param){
       	 global $m; 
   $myValue = del(self::$ps,$param,"?{$_SERVER["QUERY_STRING"]}&a=".'buylog');   
     }     
    
    
          
}
  
 
?>